import java.util.*;
import java.util.function.BiConsumer;

public  class Test {
    static class Node {
        int val;
        Node next;
        Node random;

        public Node(int val) {
            this.val = val;
            this.next = null;
            this.random = null;
        }
    }

    public static void main1(String[] args) {
        HashMap<String,Integer> map = new HashMap<>();
        map.put("hello",3);
        map.put("nihao",6);
        map.put("cnm",2);
        map.forEach(new BiConsumer<String, Integer>() {
            @Override
            public void accept(String s, Integer integer) {

            }
        });
    }
    public Node copyRandomList(Node head) {
        Node cur = head;
        Node newHead = new Node(cur.val);
        Node pre = newHead;
        cur = cur.next;
        Map<Node,Node> map = new HashMap<>();
        while(cur != null){
            Node newNode = new Node(cur.val);
            pre.next = newNode;
            cur = cur.next;
            pre = pre.next;
        }
        cur = head;
        pre = newHead;
        while (cur != null){
            map.put(cur,pre);
            cur = cur.next;
            pre = pre.next;
        }
        cur = head;
        pre = newHead;
        while (cur != null){
            pre.random = map.get(cur.random);
            pre = pre.next;
            cur = cur.next;
        }
        return newHead;
    }

    public int numJewelsInStones(String jewels, String stones) {
        int sums = 0;
        for (int i = 0; i < jewels.length(); i++) {
            for (int j = 0; j < stones.length(); j++) {
                if (jewels.charAt(i) == stones.charAt(j)){
                    sums++;
                }
            }
        }return sums;
    }
    public static int singleNumber(int[] nums) {
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < nums.length; i++) {
            if (set.contains(nums[i])){
                set.remove(nums[i]);
            }else{
                set.add(nums[i]);
            }
        }
        for (int i = 0; i < nums.length; i++) {
            if (set.contains(nums[i])){
                return nums[i];
            }
        }
        return -1;
    }
    public boolean containsDuplicate(int[] nums) {
        Set<Integer> set = new HashSet<>();
        for(int i = 0; i < nums.length; i++){
            if(set.contains(nums[i])){
                return true;
            }
            set.add(nums[i]);
        }
        return false;
    }
    /*public List<String> topKFrequent(String[] words, int k) {
        HashMap<String,Integer> map = new HashMap<>();
        for (int i = 0; i < words.length; i++) {
            if (!map.containsKey(words[i])){
                map.put(words[i],0);
            }else{
                int val = map.get(words[i]);
                map.put(words[i],val+1);
            }
        }
        PriorityQueue<Map.Entry<String,Integer>> minHeap = new PriorityQueue<>(new Comparator<Map.Entry<String, Integer>>() {
            @Override
            public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
                if (o1.getValue().equals(o2.getValue())){
                    return o2.getKey().compareTo(o1.getKey());
                }
                return o1.getValue().compareTo(o2.getValue());
            }
        });
        for (Map.Entry<String,Integer> entry:map.entrySet()) {
            if (minHeap.size() < k){
                minHeap.offer(entry);
            }else{
                if (minHeap.peek().getValue() < entry.getValue()){
                    minHeap.poll();
                    minHeap.offer(entry);
                }else if (minHeap.peek().getValue() == entry.getValue()){
                    if (minHeap.peek().getKey().compareTo(entry.getKey()) > 0){
                        minHeap.poll();
                        minHeap.offer(entry);
                    }
                }
            }
        }
        ArrayList<String> list = new ArrayList<>();
        while (!minHeap.isEmpty()){
            list.add(minHeap.poll().getKey());
        }
        Collections.reverse(list);
        return list;
    }*/

    public static void func(String str1,String str2){
        str1 = str1.toUpperCase();
        str2 = str2.toUpperCase();
        HashSet<Character> set2 = new HashSet<>();
        for (int i = 0; i < str2.length(); i++) {
            set2.add(str2.charAt(i));
        }
        HashSet<Character> error = new HashSet<>();
        for (int i = 0; i < str1.length(); i++) {
            if (!set2.contains(str1.charAt(i)) && !error.contains(str1.charAt(i))){
                error.add(str1.charAt(i));
                System.out.print(str1.charAt(i));
            }
        }

    }
    public static void main2(String[] args) {
        String str1 = "7_This_is_a_test";
        String str2 = "_hs_s_a_es";
        func(str1,str2);
    }

    public boolean containsNearbyDuplicate(int[] nums, int k) {
        HashMap<Integer,Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            if (map.containsKey(nums[i])){
                if ((map.get(nums[i]) - i) <= k ){
                    return true;
                }else{
                    return false;
                }
            }else{
                map.put(nums[i],i);
            }
        }
        return false;

    }
}
